package chat.window;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;

import chat.whiteboard.IWhiteBoardController;
import chat.whiteboard.WhiteBoardView;
import chat.whiteboard.draw.elements.Circle;
import chat.whiteboard.draw.elements.Drawing;
import chat.whiteboard.models.UserModel;



public class ChatGUI extends JFrame implements ActionListener{
	public IWhiteBoardController controller1;
	public ChatGUI(){
		super();
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
//		setLayout(new GridLayout(2,1));
        JTabbedPane jTabbedPane = new JTabbedPane();
        WhiteBoardView whiteBoard1 = new WhiteBoardView(new UserModel("Dobre", Color.green));
        WhiteBoardView whiteBoard2 = new WhiteBoardView(new UserModel("Geta", Color.red));
        WhiteBoardView whiteBoard3 = new WhiteBoardView(new UserModel("Tibi", Color.blue));
		
        jTabbedPane.add("tab1", whiteBoard1);
        jTabbedPane.add("tab2", whiteBoard2);
        jTabbedPane.add("tab3", whiteBoard3);
		this.getContentPane().add(jTabbedPane);
		setSize(700, 600);
		controller1 = whiteBoard1.getController(); 
		// add users
		controller1.addUser(new UserModel("Ionut Gabriel", Color.pink));
		controller1.addUser(new UserModel("Geta", Color.red));
		controller1.addUser(new UserModel("Tibi", Color.blue));
		for (int i = 0; i < 5; i++){
			int r = (int)(Math.random() * 255);
			int g = (int)(Math.random() * 255);
			int b = (int)(Math.random() * 255);
			Drawing d = new Circle((int)(Math.random() * 200), (int)(Math.random() * 200)).setColor(new Color(r,g,b));
			controller1.addDrawing(d);
		}
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		
	}

}
